<?php
/**
 * Created by PhpStorm.
 * User: ye
 * Date: 2017/11/18
 * Time: 上午10:53
 */

namespace App\Third;


use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Psr\Http\Message\ResponseInterface;

class Ifff {
    public function send2ifff($username_temp, $content, $avatarurl) {
        $params = [
            'value1' => $username_temp,
            'value2' => $content,
            'value3' => $avatarurl
        ];
        $client = new Client();
        $options = json_encode($params, JSON_UNESCAPED_UNICODE);
        $data = [
            'query' => [],
            'body' => $options,
            'headers' => ['content-type' => 'application/json']
        ];
        $promise = $client->requestAsync('POST', config('ifff.xcx_kf_url'), $data);
        $promise->then(
            function (ResponseInterface $res) {
//                info('---');
//                info($res->getStatusCode() . "\n");
//                info($res->getBody()->getContents() . "\n");
            },
            function (RequestException $e) {
//                info('-__-');
//                info($e->getMessage() . "\n");
            }
        );
        $promise->wait();
    }

}